import java.util.Scanner;
import java.util.ArrayList;

public final class InteractiveMath {
	public static final void main (String args[]) {
		String Line = new String();
		Scanner scan = new Scanner(System.in);
		FuIParser parse = new FuIParser("zero");
		while(true) {
			System.out.printf("<=> ");
			Line = scan.nextLine();
			Line = Line.trim();
			if(Line.length() < 6) {
				Line = Line+"     ";
			}
			if(Line.substring(0,4).compareTo("quit") == 0) {
				System.exit(0);
			}
			else if(Line.substring(0,5).compareTo("show ") == 0) {
				if(Line.contains("const") || Line.contains("var")) {
					ArrayList<String> str = parse.getConstVars();
					ArrayList<String> str2 = parse.getConstVals();
					for(int i = 0;i < str.size();i++) {
						System.out.printf("%s = %s\n",str.get(i),str2.get(i).substring(1,str2.get(i).length()-1));
					}
				}
				else if(Line.contains("def") || Line.contains("func")) {
					ArrayList<String> str = parse.getFuncVars();
					ArrayList<String> str2 = parse.getFuncVals();
					for(int i = 0;i < str.size();i++) {
						System.out.printf("%s = %s\n",str.get(i)+"(n)",str2.get(i));
					}
				}
				else {
					System.out.println(parse.Message());
				}
			}
			else if(Line.substring(0,4).compareTo("del ") == 0) {
				if(Line.contains("const") || Line.contains("var")) {
					parse.delVars();
					System.out.println(parse.Message());
				}
				else if(Line.contains("func") || Line.contains("def")) {
					parse.delFunc();
					System.out.println(parse.Message());
				}
				else {
					System.out.println(parse.Message());
				}
			}
			else {
				System.out.println(parse.Parse(Line));
			}
		}
	}
}

